/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;

import com.l2jserver.util.L2Properties;

/**
 * @author BiggBoss
 *
 */
public final class CustomConfig
{
	private static final Logger _log = Logger.getLogger(CustomConfig.class.getName());
	
	// List of custom files to load
	private static final String AIO_CONFIG_FILE = "./config/aioconfig.properties";
	
	// AIO Item configuration parameters
	public static boolean AIOITEM_ENABLEME;
	public static boolean AIOITEM_ENABLESHOP;
	public static boolean AIOITEM_ENABLEGK;
	public static boolean AIOITEM_ENABLEWH;
	public static boolean AIOITEM_ENABLEBUFF;
	public static boolean AIOITEM_ENABLESCHEMEBUFF;
	public static boolean AIOITEM_ENABLESERVICES;
	public static boolean AIOITEM_ENABLESUBCLASS;
	public static boolean AIOITEM_ENABLETOPLIST;
	public static int AIOITEM_GK_COIN;
	public static int AIOITEM_GK_PRICE;
	public static int AIOITEM_BUFF_COIN;
	public static int AIOITEM_BUFF_PRICE;
	public static int AIOITEM_SCHEME_COIN;
	public static int AIOITEM_SCHEME_PRICE;
	public static int AIOITEM_SCHEME_PROFILE_PRICE;
	public static int AIOITEM_SCHEME_MAX_PROFILES;
	public static int AIOITEM_SCHEME_MAX_PROFILE_BUFFS;
	
	public static void load()
	{
		InputStream is = null;
		try
		{
			try
			{
				L2Properties aioSettings = new L2Properties();
				is = new FileInputStream(new File(AIO_CONFIG_FILE));
				aioSettings.load(is);
				
				AIOITEM_ENABLEME = Boolean.parseBoolean(aioSettings.getProperty("EnableAIOItem", "false"));
				AIOITEM_ENABLESHOP = Boolean.parseBoolean(aioSettings.getProperty("EnableGMShop", "false"));
				AIOITEM_ENABLEGK = Boolean.parseBoolean(aioSettings.getProperty("EnableGk", "false"));
				AIOITEM_ENABLEWH = Boolean.parseBoolean(aioSettings.getProperty("EnableWh", "false"));
				AIOITEM_ENABLEBUFF = Boolean.parseBoolean(aioSettings.getProperty("EnableBuffer", "false"));
				AIOITEM_ENABLESCHEMEBUFF = Boolean.parseBoolean(aioSettings.getProperty("EnableSchemeBuffer", "false"));
				AIOITEM_ENABLESERVICES = Boolean.parseBoolean(aioSettings.getProperty("EnableServices", "false"));
				AIOITEM_ENABLESUBCLASS = Boolean.parseBoolean(aioSettings.getProperty("EnableSubclassManager", "false"));
				AIOITEM_ENABLETOPLIST = Boolean.parseBoolean(aioSettings.getProperty("EnableTopListManager", "false"));
				AIOITEM_GK_COIN = Integer.parseInt(aioSettings.getProperty("GkCoin", "57"));
				AIOITEM_GK_PRICE = Integer.parseInt(aioSettings.getProperty("GkPrice", "100"));
				AIOITEM_BUFF_COIN = Integer.parseInt(aioSettings.getProperty("BufferCoin", "57"));
				AIOITEM_BUFF_PRICE = Integer.parseInt(aioSettings.getProperty("BufferPrice", "100"));
				AIOITEM_SCHEME_COIN = Integer.parseInt(aioSettings.getProperty("SchemeCoin", "57"));
				AIOITEM_SCHEME_PRICE = Integer.parseInt(aioSettings.getProperty("SchemePrice", "100"));
				AIOITEM_SCHEME_PROFILE_PRICE = Integer.parseInt(aioSettings.getProperty("SchemeProfileCreationPrice", "1000"));
				AIOITEM_SCHEME_MAX_PROFILES = Integer.parseInt(aioSettings.getProperty("SchemeMaxProfiles", "4"));
				AIOITEM_SCHEME_MAX_PROFILE_BUFFS = Integer.parseInt(aioSettings.getProperty("SchemeMaxProfileBuffs", "24"));
			}
			catch(Exception e)
			{
				_log.warning("CustomConfig.load(): Couldn't load AIO Item settings. Reason:");
				e.printStackTrace();
			}
		}
		catch(Exception e)
		{
			_log.warning("CustomConfig.load(): Problems during initialization. Reason:");
			e.printStackTrace();
		}
		finally
		{
			try
			{
				if(is != null)
					is.close();
			}
			catch(IOException ioe)
			{
				ioe.printStackTrace();
			}
		}
	}
}
